<?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date') ?>
<title><?= $sf_response->getTitle() ?></title>
<?php use_stylesheet('/sf/sf_admin/css/main') ?>

<style type="text/css">
<!--
.style1 {
	font-size: 36px;
	font-weight: bold;
}
-->
</style>

<p align="center" class="style1">BILL OF MATERIAL</p>
<p align="left">&nbsp;</p>
<table width="100%" border="0">
  <tr>
    <td width="18%" ><p align="left"><strong>Project:</strong></p>
    </td>
    <td width="82%"><strong><?echo $bom->getProject()?></strong></td>
  </tr>
  <tr>
    <td><p align="left"><strong>Sale Confirmation No: </strong></p></td>
    <td><strong><?echo ProjectPeer::retrieveByPK($bom->getProjectId())->getSaleno()?></strong></td>
  </tr>
  <tr>
    <td><strong>Prepared by:</strong></td>
    <td><? echo $createName ?> &nbsp;</td>
  </tr>
  <tr>
    <td><strong>Date:</strong></td>
    <td><?echo date('Y-m-d')?></td>
  </tr>
</table>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td><strong>No</strong></td>
    <td><strong>Description</strong></td>
    <td><strong>Code</strong></td>
    <td><strong>Brand</strong></td>
    <td><strong>Unit</strong></td>
    <td><strong>Qty</strong></td>
    <td><strong>Stock</strong></td>
    <td><strong>Ordered</strong></td>
    <td><strong>Estimated Arriving Date </strong></td>
    <td><strong>Remarks</strong></td>
  </tr>
<?foreach ($compsList as $key=>$comps) {
    $comp = ComponentPeer::retrieveByPK($comps->getComponentId());
    $bSupplied = $comps->getQty2();
    $mrComps = null;
    if (!$bSupplied && $mr) {
        $c = new Criteria();
        $c->add(ComponentsPeer::COMPONENTGROUP_ID , $mr->getComponentgroupId());
        $c->add(ComponentsPeer::COMPONENT_ID , $comp->getId());
        $mrComps = ComponentsPeer::doSelectOne($c);
    }
?>
  <tr>
    <td><? echo $key+1?></td>
    <td><? echo $comp->getDescription()?></td>
    <td><? echo $comp->getProductcode()?></td>
    <td><? echo $comp->getBrand()?></td>
    <td><? echo $comp->getComponentunit()?></td>
    <td><? echo $comps->getQty1()?></td>    
    <td>
    <?if ($mrComps) { 
            echo $comps->getQty1() - $mrComps->getQty1();
        } elseif (!$bSupplied) {
            echo $comps->getQty1();
        }
        ?>
    </td>
    <td>
    <?if ($mrComps) { 
            echo $mrComps->getQty1();
    } elseif (!$bSupplied)
        echo '0';
    ?>
    </td>
    <td>
    <?if ($mr) { 
            echo $mr->getReqarrdate();
        }?>
        &nbsp;
    </td>
    <td>
    <?
        if ($bSupplied) echo 'Supplied by client';
        else echo '&nbsp;';
    ?>
    </td>
  </tr>
<?}?>
</table>
<?exit()?>